<?php
/**
 * @package Curly
 * @subpackage Collections
 * @version 0.9
 * @link http://curly.codeplex.com/
 * @license http://curly.codeplex.com/license The MIT License
 * @author Dawid Zawada
 */

namespace Curly\Collections
{
    /**
     * Represents a collection of keys and values, where keys are strings
     * and values can be of any type
     * 
     * @package Curly
     * @subpackage Collections
     * @license http://curly.codeplex.com/license The MIT License
     */
    class StringIndexedCollection extends Collection
    {
        /**
         * Checks whether the given key is not empty and is of type string
         * 
         * @param string $key
         * @throws \InvalidArgumentException
         */
        protected function validateKey( $key )
        {
            if( empty( $key ) )
            {
                throw new \InvalidArgumentException( "Key cannot be empty" );
            }
            if( !is_string( $key ) )
            {
                throw new \InvalidArgumentException( "Key must be a string, '" . gettype( $key ) . "' given" );
            }
        }
    }
}